﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using Microsoft.Extensions.Configuration;
using MongoDB.Bson;
using MongoDB.Driver;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            
            var filename =  "appsetting.json";
            ConfigurationBuilder builder = new ConfigurationBuilder();
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("配置文件不存在！");
            }
            else
            {
                Console.WriteLine(filename);
            }
            builder.SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile(filename);
            var config = builder.Build();
            if (string.IsNullOrEmpty(config["mongoconnectionstring"]))
            {
                throw new SyntaxErrorException("错误的配置！");
            }
            var client = new MongoClient(config["mongoconnectionstring"]);

        }
    }
}
